//
//  ZH_InstitutionsCollectionViewCell.m
//  WisdomStar
//
//  Created by zhangliwen on 2018/10/18.
//  Copyright © 2018年 zhangliwen. All rights reserved.
//

#import "ZH_InstitutionsCollectionViewCell.h"
@interface ZH_InstitutionsCollectionViewCell()
@property (nonatomic,weak)UIImageView *pngView;
@property (nonatomic,weak)UILabel *titleLabel;
@property (nonatomic,weak)UIView *lineView;
@property (nonatomic,weak)UILabel *contentLabel;
@end
@implementation ZH_InstitutionsCollectionViewCell
///注册cell
+(void)registerCollectionView:(UICollectionView*)collectionView
{
    [collectionView registerClass:[ZH_InstitutionsCollectionViewCell class] forCellWithReuseIdentifier:@"ZH_InstitutionsCollectionViewCell"];
}

///创建
+(id)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    return [collectionView dequeueReusableCellWithReuseIdentifier:@"ZH_InstitutionsCollectionViewCell" forIndexPath:indexPath];
}
//初始化
-(void)initDefault
{
    
}
///加载子视图约束
-(void)loadSubviewConstraints
{
    [self.pngView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.contentView).offset(FITSCALE(15));
        make.width.mas_equalTo(FITSCALE(62));
        make.height.mas_equalTo(FITSCALE(62));
        make.centerX.equalTo(self.contentView);
    }];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.pngView.mas_bottom).offset(FITSCALE(15));
        make.centerX.equalTo(self.contentView);
        make.left.right.equalTo(self.contentView);
        make.height.mas_equalTo(FITSCALE(13));
    }];
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(FITSCALE(14));
        make.left.equalTo(self.contentView).offset(FITSCALE(5));
        make.right.equalTo(self.contentView).offset(FITSCALE(-5));
        make.height.mas_equalTo(FITSCALE(1));
    }];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.lineView.mas_bottom).offset(FITSCALE(15));
        make.left.equalTo(self.contentView).offset(FITSCALE(11));
        make.right.equalTo(self.contentView).offset(FITSCALE(-11));
        make.bottom.equalTo(self.contentView);
    }];
    
}
- (void)updateUI:(NSMutableDictionary *)data{
    if (data) {
        [self.pngView sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",SERVER_TEST,data[@"head"]]] placeholderImage:nil];
        self.titleLabel.text = data[@"nickname"];
        self.contentLabel.text = data[@"sign"];
    }
}
#pragma mark - getter,setter
- (UIImageView *)pngView{
    if (!_pngView) {
        UIImageView *image = [UIImageView createImageViewWithName:@""];
        image.backgroundColor = kFontColorRed;
        image.contentMode = UIViewContentModeScaleToFill;
        image.layer.cornerRadius = FITSCALE(31);
        image.layer.masksToBounds = YES;
        [self.contentView addSubview:_pngView = image];
    }
    return _pngView;
}
- (UILabel *)titleLabel{
    if (!_titleLabel) {
        UILabel *label = [UILabel createLabelWithText:@"机构名称..." font:kFontSize_26];
        label.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_titleLabel = label];
    }
    return _titleLabel;
}
- (UIView *)lineView{
    if (!_lineView) {
        UIView *view = [UIView createViewWithBackgroundColor:[UIColor colorWithHexString:@"#DFDFDF"]];
        [self.contentView addSubview:_lineView = view];
    }
    return _lineView;
}
- (UILabel *)contentLabel{
    if (!_contentLabel) {
        UILabel *label = [UILabel createLabelWithText:@"机构介绍, 机构介绍, 机构介绍..." font:kFontSize_24];
        label.textColor = [UIColor colorWithHexString:@"#808080"];
        [label lableAutoLinefeed];
        [self.contentView addSubview:_contentLabel = label];
    }
    return _contentLabel;
}
@end
